<template>
  <row>
    <i-col :xs="0" :md="8">
      <div class="left-block">
        <svg width="83px" height="82px" viewBox="0 0 83 82">
          <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
            <g transform="translate(-157.000000, -414.000000)">
              <rect
                fill="url(#linearGradient-1)"
                x="0"
                y="0"
                width="396"
                height="962"
              ></rect>
              <g
                transform="translate(157.000000, 414.000000)"
                fill="#FFFFFF"
                fill-rule="nonzero"
              >
                <path
                  d="M70.8692388,2.89982858 C72.0644388,1.14924655 74.0778113,0 76.36,0 C80.0271475,0 83,2.96754095 83,6.62815004 C83,10.2887591 80.0271475,13.2563001 76.36,13.2563001 C74.0778113,13.2563001 72.0644388,12.1070535 70.8692388,10.3564715 L24.38125,10.3564715 C17.7917763,10.3564715 12.45,15.6887684 12.45,22.2664965 C12.45,28.8441211 17.7917763,34.176418 24.38125,34.176418 L58.61875,34.176418 C69.3337388,34.176418 78.02,42.8472244 78.02,53.543086 C78.02,64.2389476 69.3337388,72.909754 58.61875,72.909754 L22.2025,72.909754 C21.7441037,72.909754 21.3725,72.5389178 21.3725,72.0814682 L21.3725,66.2813968 C21.3725,65.8239472 21.7441037,65.453111 22.2025,65.453111 L58.61875,65.453111 C65.2082238,65.453111 70.55,60.1208141 70.55,53.543086 C70.55,46.9654614 65.2082238,41.633061 58.61875,41.633061 L24.38125,41.633061 C13.6662613,41.633061 4.98,32.9623581 4.98,22.2664965 C4.98,11.5705314 13.6662613,2.89982858 24.38125,2.89982858 L70.8692388,2.89982858 Z M16.9874025,69.8383667 L1.3352625,81.828839 C1.08458451,82.020788 0.746438234,82.0540509 0.463029767,81.9146391 C0.179621299,81.7752273 0,81.487325 0,81.1720083 L0,57.1908567 C0,56.8754649 0.179496843,56.5874456 0.462959696,56.4479739 C0.746422548,56.3085022 1.08465882,56.3417848 1.33536625,56.533819 L16.9874025,68.5242913 C17.1920522,68.6810553 17.3120188,68.9238728 17.3120188,69.181329 C17.3120188,69.4387851 17.1920522,69.6816026 16.9874025,69.8383667 L16.9874025,69.8383667 Z"
                  id="形状"
                ></path>
              </g>
            </g>
          </g>
        </svg>
        <p class="subtitle">生猪溯源系统</p>
      </div>
    </i-col>
    <i-col :xs="24" :md="16">
      <div class="right-container">
        <div class="inner">
          <p class="title">登录</p>
          <Form>
            <FormItem style="font-size: 12px" :label-width="54" label="用户名">
              <Input style="width: 230px" v-model="uTel"></Input>
            </FormItem>
            <FormItem style="font-size=12px" :label-width="54" label="密码">
              <Input v-model="uPwd" type="password"></Input>
            </FormItem>
          </Form>
          <i-button
            style="margin-top: 44px"
            long
            type="primary"
            @click="login()"
            >登录</i-button
          >
          <router-link to="/register" class="link"
            >没有账号？去注册 !</router-link
          >
          <row>
            <i-col :xs="24" :md="0">
              <div class="lift"></div>
            </i-col>
          </row>
        </div>
      </div>
    </i-col>
  </row>
</template>

<script>
import Axios from "axios";
import { postRequset } from "../libs/fetch";
export default {
  name: "Login",
  data() {
    return {
      uTel: "",
      uPwd: "",
    };
  },
  components: {},
  methods: {
    login() {
      postRequset("/sy-user/login",{
        utel: this.uTel,
        upwd: this.uPwd,
      })
        .then((res) => {
          localStorage.setItem("token", res.data.token);
          localStorage.setItem("uType", res.data.uType);
          if(localStorage.getItem("uType")==1){
            this.$router.push("/sQueryFarms");
          }
          if(localStorage.getItem("uType")==2){
            this.$router.push("/pQuerySalers");
          }
          if(localStorage.getItem("uType")==3){
            this.$router.push("/rQueryRetailers");
          }
          if(localStorage.getItem("uType")==4){
            this.$router.push("/checkIn");
          }
          if(localStorage.getItem("uType")==5){
            this.$router.push("/manager");
          }
        })
        .catch((error) => {
          console.log("sadadadasd");
          console.log(error);
          if(error.code=="100003"){
            this.$Message.info('您尚未通过审核！');
          }
        });
    },
  },
};
</script>

<style scoped lang="less">
.ivu-form-item {
  margin: 0;
  margin-top: 15px;
  vertical-align: top;
  zoom: 1;
}
.subtitle {
  margin-top: 20px;
  font-size: 24px;
  font-weight: 400;
  color: #ffffff;
  line-height: 33px;
}
.left-block {
  //width: 396px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(180deg, #3ebbf9 0%, rgba(29, 134, 240, 0.8) 100%);
}
.right-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: #ffffff;
}
.inner {
  width: 282px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.text {
  width: 42px;
  font-size: 12px;
  font-weight: 400;
  color: #565e66;
  line-height: 20px;
  margin-right: 10px;
  text-align: right;
}
.label-container {
  width: 282px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
}
.title {
  margin-left: 2px;
  width: 100%;
  text-align: left;
  font-size: 36px;
  font-weight: 400;
  color: #0e1114;
  line-height: 50px;
}
.link {
  width: 100%;
  text-align: right;
  font-size: 9px;
  font-weight: 400;
  color: #1d86f0;
  line-height: 13px;
  margin-top: 10px;
  cursor: pointer;
}
.lift {
  height: 45vh;
}
</style>
